package com.huike.clues.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.huike.clues.domain.vo.ImportDataVO;
import com.huike.clues.domain.vo.TbClueExcelVo;
import com.huike.clues.service.ITbClueService;

import java.util.List;
import java.util.Map;

/**
 * @author EthanRuins
 * @date 2023/7/13
 * @apiNote
 */
public class ClueExcelListener extends AnalysisEventListener<TbClueExcelVo> {
    private final ITbClueService clueService;
    private final ImportDataVO importDataVO;

    public ClueExcelListener(ITbClueService clueService, ImportDataVO importDataVO) {
        this.clueService = clueService;
        this.importDataVO = importDataVO;
    }

    public ImportDataVO getResult() {
        return importDataVO;
    }

    @Override
    public void invoke(TbClueExcelVo tbClueExcelVo, AnalysisContext analysisContext) {
        ImportDataVO addClue = clueService.importCluesData(tbClueExcelVo);
        importDataVO.addAll(addClue);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
